
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/solvers/pde.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:35 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>PDE &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="pde.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Physics" href="../physics/index.html" />
    <link rel="prev" title="Parsing" href="../parsing.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../physics/index.html" title="Physics"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../parsing.html" title="Parsing"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" accesskey="U">SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">PDE</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="pde">
<span id="pde-docs"></span><h1>PDE<a class="headerlink" href="#pde" title="Permalink to this headline">¶</a></h1>
<section id="user-functions">
<h2>User Functions<a class="headerlink" href="#user-functions" title="Permalink to this headline">¶</a></h2>
<p>These are functions that are imported into the global namespace with <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">sympy</span> <span class="pre">import</span> <span class="pre">*</span></code>.  They are intended for user use.</p>
<section id="pde-separate">
<h3>pde_separate<a class="headerlink" href="#pde-separate" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_separate">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_separate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fun</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strategy</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'mul'</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L821-L908"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_separate" title="Permalink to this definition">¶</a></dt>
<dd><p>Separate variables in partial differential equation either by additive
or multiplicative separation approach. It tries to rewrite an equation so
that one of the specified variables occurs on a different side of the
equation than the others.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>eq</strong> – Partial differential equation</p></li>
<li><p><strong>fun</strong> – Original function F(x, y, z)</p></li>
<li><p><strong>sep</strong> – List of separated functions [X(x), u(y, z)]</p></li>
<li><p><strong>strategy</strong> – Separation strategy. You can choose between additive
separation (‘add’) and multiplicative separation (‘mul’) which is
default.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">E</span><span class="p">,</span> <span class="n">Eq</span><span class="p">,</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pde_separate</span><span class="p">,</span> <span class="n">Derivative</span> <span class="k">as</span> <span class="n">D</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">t</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">T</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">Function</span><span class="p">,</span> <span class="s1">&#39;uXT&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">E</span><span class="o">**</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">))</span><span class="o">*</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">t</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pde_separate</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">T</span><span class="p">(</span><span class="n">t</span><span class="p">)],</span> <span class="n">strategy</span><span class="o">=</span><span class="s1">&#39;add&#39;</span><span class="p">)</span>
<span class="go">[exp(-X(x))*Derivative(X(x), x), exp(T(t))*Derivative(T(t), t)]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">t</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pde_separate</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">T</span><span class="p">(</span><span class="n">t</span><span class="p">)],</span> <span class="n">strategy</span><span class="o">=</span><span class="s1">&#39;mul&#39;</span><span class="p">)</span>
<span class="go">[Derivative(X(x), (x, 2))/X(x), Derivative(T(t), (t, 2))/T(t)]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.solvers.pde.pde_separate_add" title="sympy.solvers.pde.pde_separate_add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pde_separate_add</span></code></a>, <a class="reference internal" href="#sympy.solvers.pde.pde_separate_mul" title="sympy.solvers.pde.pde_separate_mul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pde_separate_mul</span></code></a></p>
</div>
</dd></dl>

</section>
<section id="pde-separate-add">
<h3>pde_separate_add<a class="headerlink" href="#pde-separate-add" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_separate_add">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_separate_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fun</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L911-L933"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_separate_add" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function for searching additive separable solutions.</p>
<p>Consider an equation of two independent variables x, y and a dependent
variable w, we look for the product of two functions depending on different
arguments:</p>
<p><span class="math notranslate nohighlight">\(w(x, y, z) = X(x) + y(y, z)\)</span></p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">E</span><span class="p">,</span> <span class="n">Eq</span><span class="p">,</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pde_separate_add</span><span class="p">,</span> <span class="n">Derivative</span> <span class="k">as</span> <span class="n">D</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">t</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">T</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">Function</span><span class="p">,</span> <span class="s1">&#39;uXT&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">x</span><span class="p">),</span> <span class="n">E</span><span class="o">**</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">))</span><span class="o">*</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="n">t</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pde_separate_add</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">),</span> <span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">T</span><span class="p">(</span><span class="n">t</span><span class="p">)])</span>
<span class="go">[exp(-X(x))*Derivative(X(x), x), exp(T(t))*Derivative(T(t), t)]</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="pde-separate-mul">
<h3>pde_separate_mul<a class="headerlink" href="#pde-separate-mul" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_separate_mul">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_separate_mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fun</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sep</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L936-L958"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_separate_mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Helper function for searching multiplicative separable solutions.</p>
<p>Consider an equation of two independent variables x, y and a dependent
variable w, we look for the product of two functions depending on different
arguments:</p>
<p><span class="math notranslate nohighlight">\(w(x, y, z) = X(x)*u(y, z)\)</span></p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">Eq</span><span class="p">,</span> <span class="n">pde_separate_mul</span><span class="p">,</span> <span class="n">Derivative</span> <span class="k">as</span> <span class="n">D</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">Y</span> <span class="o">=</span> <span class="nb">map</span><span class="p">(</span><span class="n">Function</span><span class="p">,</span> <span class="s1">&#39;uXY&#39;</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">x</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">D</span><span class="p">(</span><span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">y</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pde_separate_mul</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">u</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="p">[</span><span class="n">X</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="n">Y</span><span class="p">(</span><span class="n">y</span><span class="p">)])</span>
<span class="go">[Derivative(X(x), (x, 2))/X(x), Derivative(Y(y), (y, 2))/Y(y)]</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="pdsolve">
<h3>pdsolve<a class="headerlink" href="#pdsolve" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pdsolve">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pdsolve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hint</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'default'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solvefun</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L64-L196"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pdsolve" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves any (supported) kind of partial differential equation.</p>
<p><strong>Usage</strong></p>
<blockquote>
<div><p>pdsolve(eq, f(x,y), hint) -&gt; Solve partial differential equation
eq for function f(x,y), using method hint.</p>
</div></blockquote>
<p><strong>Details</strong></p>
<blockquote>
<div><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">eq</span></code> can be any supported partial differential equation (see</dt><dd><p>the pde docstring for supported methods).  This can either
be an Equality, or an expression, which is assumed to be
equal to 0.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">f(x,y)</span></code> is a function of two variables whose derivatives in that</dt><dd><p>variable make up the partial differential equation. In many
cases it is not necessary to provide this; it will be autodetected
(and an error raised if it couldn’t be detected).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">hint</span></code> is the solving method that you want pdsolve to use.  Use</dt><dd><p>classify_pde(eq, f(x,y)) to get all of the possible hints for
a PDE.  The default hint, ‘default’, will use whatever hint
is returned first by classify_pde().  See Hints below for
more options that you can use for hint.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">solvefun</span></code> is the convention used for arbitrary functions returned</dt><dd><p>by the PDE solver. If not set by the user, it is set by default
to be F.</p>
</dd>
</dl>
</div></blockquote>
<p><strong>Hints</strong></p>
<blockquote>
<div><p>Aside from the various solving methods, there are also some
meta-hints that you can pass to pdsolve():</p>
<dl class="simple">
<dt>“default”:</dt><dd><p>This uses whatever hint is returned first by
classify_pde(). This is the default argument to
pdsolve().</p>
</dd>
<dt>“all”:</dt><dd><p>To make pdsolve apply all relevant classification hints,
use pdsolve(PDE, func, hint=”all”).  This will return a
dictionary of hint:solution terms.  If a hint causes
pdsolve to raise the NotImplementedError, value of that
hint’s key will be the exception object raised.  The
dictionary will also include some special keys:</p>
<ul class="simple">
<li><p>order: The order of the PDE.  See also ode_order() in
deutils.py</p></li>
<li><p>default: The solution that would be returned by
default.  This is the one produced by the hint that
appears first in the tuple returned by classify_pde().</p></li>
</ul>
</dd>
<dt>“all_Integral”:</dt><dd><p>This is the same as “all”, except if a hint also has a
corresponding “_Integral” hint, it only returns the
“_Integral” hint.  This is useful if “all” causes
pdsolve() to hang because of a difficult or impossible
integral.  This meta-hint will also be much faster than
“all”, because integrate() is an expensive routine.</p>
</dd>
</dl>
<p>See also the classify_pde() docstring for more info on hints,
and the pde docstring for a list of all supported hints.</p>
</div></blockquote>
<dl>
<dt><strong>Tips</strong></dt><dd><ul>
<li><p>You can declare the derivative of an unknown function this way:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">Derivative</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="c1"># x and y are the independent variables</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s2">&quot;f&quot;</span><span class="p">)(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span> <span class="c1"># f is a function of x and y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># fx will be the partial derivative of f with respect to x</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fx</span> <span class="o">=</span> <span class="n">Derivative</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1"># fy will be the partial derivative of f with respect to y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">fy</span> <span class="o">=</span> <span class="n">Derivative</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>See test_pde.py for many tests, which serves also as a set of
examples for how to use pdsolve().</p></li>
<li><p>pdsolve always returns an Equality class (except for the case
when the hint is “all” or “all_Integral”). Note that it is not possible
to get an explicit solution for f(x, y) as in the case of ODE’s</p></li>
<li><p>Do help(pde.pde_hintname) to get help more information on a
specific hint</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers.pde</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">Eq</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ux</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uy</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="p">(</span><span class="n">ux</span><span class="o">/</span><span class="n">u</span><span class="p">))</span> <span class="o">+</span> <span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="p">(</span><span class="n">uy</span><span class="o">/</span><span class="n">u</span><span class="p">)),</span> <span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pdsolve</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">Eq(f(x, y), F(3*x - 2*y)*exp(-2*x/13 - 3*y/13))</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="classify-pde">
<h3>classify_pde<a class="headerlink" href="#classify-pde" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.classify_pde">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">classify_pde</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dict</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prep</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L231-L387"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.classify_pde" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a tuple of possible pdsolve() classifications for a PDE.</p>
<p>The tuple is ordered so that first item is the classification that
pdsolve() uses to solve the PDE by default.  In general,
classifications near the beginning of the list will produce
better solutions faster than those near the end, though there are
always exceptions.  To make pdsolve use a different classification,
use pdsolve(PDE, func, hint=&lt;classification&gt;).  See also the pdsolve()
docstring for different meta-hints you can use.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">dict</span></code> is true, classify_pde() will return a dictionary of
hint:match expression terms. This is intended for internal use by
pdsolve().  Note that because dictionaries are ordered arbitrarily,
this will most likely not be in the same order as the tuple.</p>
<p>You can get help on different hints by doing help(pde.pde_hintname),
where hintname is the name of the hint without “_Integral”.</p>
<p>See sympy.pde.allhints or the sympy.pde docstring for a list of all
supported hints that can be returned from classify_pde.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers.pde</span> <span class="kn">import</span> <span class="n">classify_pde</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">Eq</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ux</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uy</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">Eq</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="p">(</span><span class="n">ux</span><span class="o">/</span><span class="n">u</span><span class="p">))</span> <span class="o">+</span> <span class="p">(</span><span class="mi">3</span><span class="o">*</span><span class="p">(</span><span class="n">uy</span><span class="o">/</span><span class="n">u</span><span class="p">)),</span> <span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">classify_pde</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">(&#39;1st_linear_constant_coeff_homogeneous&#39;,)</span>
</pre></div>
</div>
</dd></dl>

</section>
<section id="checkpdesol">
<h3>checkpdesol<a class="headerlink" href="#checkpdesol" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.checkpdesol">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">checkpdesol</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">pde</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sol</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solve_for_func</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L390-L480"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.checkpdesol" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the given solution satisfies the partial differential
equation.</p>
<p>pde is the partial differential equation which can be given in the
form of an equation or an expression. sol is the solution for which
the pde is to be checked. This can also be given in an equation or
an expression form. If the function is not provided, the helper
function _preprocess from deutils is used to identify the function.</p>
<p>If a sequence of solutions is passed, the same sort of container will be
used to return the result for each solution.</p>
<p>The following methods are currently being implemented to check if the
solution satisfies the PDE:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>Directly substitute the solution in the PDE and check. If the
solution hasn’t been solved for f, then it will solve for f
provided solve_for_func hasn’t been set to False.</p></li>
</ol>
</div></blockquote>
<p>If the solution satisfies the PDE, then a tuple (True, 0) is returned.
Otherwise a tuple (False, expr) where expr is the value obtained
after substituting the solution in the PDE. However if a known solution
returns False, it may be due to the inability of doit() to simplify it to zero.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">symbols</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers.pde</span> <span class="kn">import</span> <span class="n">checkpdesol</span><span class="p">,</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;x y&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="mi">2</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">sol</span> <span class="o">=</span> <span class="n">pdsolve</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">assert</span> <span class="n">checkpdesol</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">sol</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">checkpdesol</span><span class="p">(</span><span class="n">eq</span><span class="p">,</span> <span class="n">sol</span><span class="p">)</span>
<span class="go">(False, (x*F(4*x - 3*y) - 6*F(4*x - 3*y)/25 + 4*Subs(Derivative(F(_xi_1), _xi_1), _xi_1, 4*x - 3*y))*exp(-6*x/25 - 8*y/25))</span>
</pre></div>
</div>
</dd></dl>

</section>
</section>
<section id="hint-methods">
<h2>Hint Methods<a class="headerlink" href="#hint-methods" title="Permalink to this headline">¶</a></h2>
<p>These functions are meant for internal use. However they contain useful information on the various solving methods.</p>
<section id="pde-1st-linear-constant-coeff-homogeneous">
<h3>pde_1st_linear_constant_coeff_homogeneous<a class="headerlink" href="#pde-1st-linear-constant-coeff-homogeneous" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_1st_linear_constant_coeff_homogeneous">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_1st_linear_constant_coeff_homogeneous</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">match</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solvefun</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L484-L555"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_1st_linear_constant_coeff_homogeneous" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves a first order linear homogeneous
partial differential equation with constant coefficients.</p>
<p>The general form of this partial differential equation is</p>
<div class="math notranslate nohighlight">
\[a \frac{\partial f(x,y)}{\partial x}
+ b \frac{\partial f(x,y)}{\partial y} + c f(x,y) = 0\]</div>
<p>where <span class="math notranslate nohighlight">\(a\)</span>, <span class="math notranslate nohighlight">\(b\)</span> and <span class="math notranslate nohighlight">\(c\)</span> are constants.</p>
<p>The general solution is of the form:</p>
<div class="math notranslate nohighlight">
\[f(x, y) = F(- a y + b x ) e^{- \frac{c (a x + b y)}{a^2 + b^2}}\]</div>
<p>and can be found in SymPy with <code class="docutils literal notranslate"><span class="pre">pdsolve</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ux</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uy</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">genform</span> <span class="o">=</span> <span class="n">a</span><span class="o">*</span><span class="n">ux</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">uy</span> <span class="o">+</span> <span class="n">c</span><span class="o">*</span><span class="n">u</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">genform</span><span class="p">)</span>
<span class="go">  d               d</span>
<span class="go">a*--(f(x, y)) + b*--(f(x, y)) + c*f(x, y)</span>
<span class="go">  dx              dy</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">pdsolve</span><span class="p">(</span><span class="n">genform</span><span class="p">))</span>
<span class="go">                         -c*(a*x + b*y)</span>
<span class="go">                         ---------------</span>
<span class="go">                              2    2</span>
<span class="go">                             a  + b</span>
<span class="go">f(x, y) = F(-a*y + b*x)*e</span>
</pre></div>
</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pdsolve</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">))</span>
<span class="go">Eq(f(x, y), F(x - y)*exp(-x/2 - y/2))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">pdsolve</span><span class="p">(</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)))</span>
<span class="go">                      x   y</span>
<span class="go">                    - - - -</span>
<span class="go">                      2   2</span>
<span class="go">f(x, y) = F(x - y)*e</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ul class="simple">
<li><p>Viktor Grigoryan, “Partial Differential Equations”
Math 124A - Fall 2010, pp.7</p></li>
</ul>
</dd></dl>

</section>
<section id="pde-1st-linear-constant-coeff">
<h3>pde_1st_linear_constant_coeff<a class="headerlink" href="#pde-1st-linear-constant-coeff" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_1st_linear_constant_coeff">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_1st_linear_constant_coeff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">match</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solvefun</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L558-L672"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_1st_linear_constant_coeff" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves a first order linear partial differential equation
with constant coefficients.</p>
<p>The general form of this partial differential equation is</p>
<div class="math notranslate nohighlight">
\[a \frac{\partial f(x,y)}{\partial x}
+ b \frac{\partial f(x,y)}{\partial y}
+ c f(x,y) = G(x,y)\]</div>
<p>where <span class="math notranslate nohighlight">\(a\)</span>, <span class="math notranslate nohighlight">\(b\)</span> and <span class="math notranslate nohighlight">\(c\)</span> are constants and <span class="math notranslate nohighlight">\(G(x, y)\)</span> can be an arbitrary
function in <span class="math notranslate nohighlight">\(x\)</span> and <span class="math notranslate nohighlight">\(y\)</span>.</p>
<p>The general solution of the PDE is:</p>
<div class="math notranslate nohighlight">
\[\begin{split}f(x, y) = \left. \left[F(\eta) + \frac{1}{a^2 + b^2}
\int\limits^{a x + b y} G\left(\frac{a \xi + b \eta}{a^2 + b^2},
\frac{- a \eta + b \xi}{a^2 + b^2} \right)
e^{\frac{c \xi}{a^2 + b^2}}\, d\xi\right]
e^{- \frac{c \xi}{a^2 + b^2}}
\right|_{\substack{\eta=- a y + b x\\ \xi=a x + b y }}\, ,\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(F(\eta)\)</span> is an arbitrary single-valued function. The solution
can be found in SymPy with <code class="docutils literal notranslate"><span class="pre">pdsolve</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">G</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;G&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ux</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uy</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">genform</span> <span class="o">=</span> <span class="n">a</span><span class="o">*</span><span class="n">ux</span> <span class="o">+</span> <span class="n">b</span><span class="o">*</span><span class="n">uy</span> <span class="o">+</span> <span class="n">c</span><span class="o">*</span><span class="n">u</span> <span class="o">-</span> <span class="n">G</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">genform</span><span class="p">)</span>
<span class="go">  d               d</span>
<span class="go">a*--(f(x, y)) + b*--(f(x, y)) + c*f(x, y) - G(x, y)</span>
<span class="go">  dx              dy</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">pdsolve</span><span class="p">(</span><span class="n">genform</span><span class="p">,</span> <span class="n">hint</span><span class="o">=</span><span class="s1">&#39;1st_linear_constant_coeff_Integral&#39;</span><span class="p">))</span>
<span class="go">          //          a*x + b*y                                             \</span>
<span class="go">          ||              /                                                 |</span>
<span class="go">          ||             |                                                  |</span>
<span class="go">          ||             |                                       c*xi       |</span>
<span class="go">          ||             |                                     -------      |</span>
<span class="go">          ||             |                                      2    2      |</span>
<span class="go">          ||             |      /a*xi + b*eta  -a*eta + b*xi\  a  + b       |</span>
<span class="go">          ||             |     G|------------, -------------|*e        d(xi)|</span>
<span class="go">          ||             |      |   2    2         2    2   |               |</span>
<span class="go">          ||             |      \  a  + b         a  + b    /               |</span>
<span class="go">          ||             |                                                  |</span>
<span class="go">          ||            /                                                   |</span>
<span class="go">          ||                                                                |</span>
<span class="go">f(x, y) = ||F(eta) + -------------------------------------------------------|*</span>
<span class="go">          ||                                  2    2                        |</span>
<span class="go">          \\                                 a  + b                         /</span>

<span class="go">        \|</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">        ||</span>
<span class="go">  -c*xi ||</span>
<span class="go"> -------||</span>
<span class="go">  2    2||</span>
<span class="go"> a  + b ||</span>
<span class="go">e       ||</span>
<span class="go">        ||</span>
<span class="go">        /|eta=-a*y + b*x, xi=a*x + b*y</span>
</pre></div>
</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers.pde</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span><span class="p">,</span> <span class="n">exp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span> <span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mi">4</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="mi">5</span><span class="o">*</span><span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span> <span class="o">-</span> <span class="n">exp</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pdsolve</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">Eq(f(x, y), (F(4*x + 2*y) + exp(x/2 + 4*y)/15)*exp(x/2 - y))</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ul class="simple">
<li><p>Viktor Grigoryan, “Partial Differential Equations”
Math 124A - Fall 2010, pp.7</p></li>
</ul>
</dd></dl>

</section>
<section id="pde-1st-linear-variable-coeff">
<h3>pde_1st_linear_variable_coeff<a class="headerlink" href="#pde-1st-linear-variable-coeff" title="Permalink to this headline">¶</a></h3>
<dl class="py function">
<dt class="sig sig-object py" id="sympy.solvers.pde.pde_1st_linear_variable_coeff">
<span class="sig-prename descclassname"><span class="pre">sympy.solvers.pde.</span></span><span class="sig-name descname"><span class="pre">pde_1st_linear_variable_coeff</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">eq</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">order</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">match</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solvefun</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/solvers/pde.py#L675-L802"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.solvers.pde.pde_1st_linear_variable_coeff" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves a first order linear partial differential equation
with variable coefficients. The general form of this partial
differential equation is</p>
<div class="math notranslate nohighlight">
\[a(x, y) \frac{\partial f(x, y)}{\partial x}
+ b(x, y) \frac{\partial f(x, y)}{\partial y}
+ c(x, y) f(x, y) = G(x, y)\]</div>
<p>where <span class="math notranslate nohighlight">\(a(x, y)\)</span>, <span class="math notranslate nohighlight">\(b(x, y)\)</span>, <span class="math notranslate nohighlight">\(c(x, y)\)</span> and <span class="math notranslate nohighlight">\(G(x, y)\)</span> are arbitrary
functions in <span class="math notranslate nohighlight">\(x\)</span> and <span class="math notranslate nohighlight">\(y\)</span>. This PDE is converted into an ODE by
making the following transformation:</p>
<ol class="arabic simple">
<li><p><span class="math notranslate nohighlight">\(\xi\)</span> as <span class="math notranslate nohighlight">\(x\)</span></p></li>
<li><p><span class="math notranslate nohighlight">\(\eta\)</span> as the constant in the solution to the differential
equation <span class="math notranslate nohighlight">\(\frac{dy}{dx} = -\frac{b}{a}\)</span></p></li>
</ol>
<p>Making the previous substitutions reduces it to the linear ODE</p>
<div class="math notranslate nohighlight">
\[a(\xi, \eta)\frac{du}{d\xi} + c(\xi, \eta)u - G(\xi, \eta) = 0\]</div>
<p>which can be solved using <code class="docutils literal notranslate"><span class="pre">dsolve</span></code>.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">G</span><span class="p">,</span> <span class="n">f</span><span class="o">=</span> <span class="p">[</span><span class="n">Function</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;G&#39;</span><span class="p">,</span> <span class="s1">&#39;f&#39;</span><span class="p">]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">f</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ux</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uy</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">genform</span> <span class="o">=</span> <span class="n">a</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="n">u</span> <span class="o">+</span> <span class="n">b</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="n">ux</span> <span class="o">+</span> <span class="n">c</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span><span class="o">*</span><span class="n">uy</span> <span class="o">-</span> <span class="n">G</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">genform</span><span class="p">)</span>
<span class="go">                                     d                     d</span>
<span class="go">-G(x, y) + a(x, y)*f(x, y) + b(x, y)*--(f(x, y)) + c(x, y)*--(f(x, y))</span>
<span class="go">                                     dx                    dy</span>
</pre></div>
</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.solvers.pde</span> <span class="kn">import</span> <span class="n">pdsolve</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">f</span> <span class="o">=</span> <span class="n">Function</span><span class="p">(</span><span class="s1">&#39;f&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">eq</span> <span class="o">=</span>  <span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> <span class="o">-</span> <span class="n">y</span><span class="o">*</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">diff</span><span class="p">(</span><span class="n">y</span><span class="p">))</span> <span class="o">+</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span><span class="o">*</span><span class="n">u</span> <span class="o">-</span> <span class="n">y</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pdsolve</span><span class="p">(</span><span class="n">eq</span><span class="p">)</span>
<span class="go">Eq(f(x, y), F(x*y)*exp(y**2/2) + 1)</span>
</pre></div>
</div>
<p class="rubric">References</p>
<ul class="simple">
<li><p>Viktor Grigoryan, “Partial Differential Equations”
Math 124A - Fall 2010, pp.7</p></li>
</ul>
</dd></dl>

</section>
</section>
<section id="module-sympy.solvers.pde">
<span id="information-on-the-pde-module"></span><h2>Information on the pde module<a class="headerlink" href="#module-sympy.solvers.pde" title="Permalink to this headline">¶</a></h2>
<p>This module contains pdsolve() and different helper functions that it
uses. It is heavily inspired by the ode module and hence the basic
infrastructure remains the same.</p>
<p><strong>Functions in this module</strong></p>
<blockquote>
<div><p>These are the user functions in this module:</p>
<ul class="simple">
<li><p>pdsolve()     - Solves PDE’s</p></li>
<li><p>classify_pde() - Classifies PDEs into possible hints for dsolve().</p></li>
<li><dl class="simple">
<dt>pde_separate() - Separate variables in partial differential equation either by</dt><dd><p>additive or multiplicative separation approach.</p>
</dd>
</dl>
</li>
</ul>
<p>These are the helper functions in this module:</p>
<ul class="simple">
<li><p>pde_separate_add() - Helper function for searching additive separable solutions.</p></li>
<li><dl class="simple">
<dt>pde_separate_mul() - Helper function for searching multiplicative</dt><dd><p>separable solutions.</p>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p><strong>Currently implemented solver methods</strong></p>
<p>The following methods are implemented for solving partial differential
equations.  See the docstrings of the various pde_hint() functions for
more information on each (run help(pde)):</p>
<blockquote>
<div><ul class="simple">
<li><p>1st order linear homogeneous partial differential equations
with constant coefficients.</p></li>
<li><p>1st order linear general partial differential equations
with constant coefficients.</p></li>
<li><p>1st order linear partial differential equations with
variable coefficients.</p></li>
</ul>
</div></blockquote>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">PDE</a><ul>
<li><a class="reference internal" href="#user-functions">User Functions</a><ul>
<li><a class="reference internal" href="#pde-separate">pde_separate</a></li>
<li><a class="reference internal" href="#pde-separate-add">pde_separate_add</a></li>
<li><a class="reference internal" href="#pde-separate-mul">pde_separate_mul</a></li>
<li><a class="reference internal" href="#pdsolve">pdsolve</a></li>
<li><a class="reference internal" href="#classify-pde">classify_pde</a></li>
<li><a class="reference internal" href="#checkpdesol">checkpdesol</a></li>
</ul>
</li>
<li><a class="reference internal" href="#hint-methods">Hint Methods</a><ul>
<li><a class="reference internal" href="#pde-1st-linear-constant-coeff-homogeneous">pde_1st_linear_constant_coeff_homogeneous</a></li>
<li><a class="reference internal" href="#pde-1st-linear-constant-coeff">pde_1st_linear_constant_coeff</a></li>
<li><a class="reference internal" href="#pde-1st-linear-variable-coeff">pde_1st_linear_variable_coeff</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-sympy.solvers.pde">Information on the pde module</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="../parsing.html"
                        title="previous chapter">Parsing</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../physics/index.html"
                        title="next chapter">Physics</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/solvers/pde.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../physics/index.html" title="Physics"
             >next</a> |</li>
        <li class="right" >
          <a href="../parsing.html" title="Parsing"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">PDE</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/solvers/pde.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:24:36 GMT -->
</html>